package com.example.controller;

import com.example.feign.UserFeign;
import com.example.service.CodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author lbq
 * @version 1.0
 * @date 2021/3/13 22:48
 */
@RestController
@RequestMapping("/code")
public class CodeController {

    @Autowired
    private CodeService codeService;

    /**
     * 发送验证码到邮箱
     *
     * @param email 邮箱地址
     * @return
     */
    @GetMapping("/create/{email}")
    public String create(@PathVariable("email") String email) {
        return codeService.create(email);
    }

    /**
     * 校验验证码是否正确
     *
     * @param email 邮箱地址
     * @param code  验证码
     * @return
     */
    @GetMapping("/validate/{email}/{code}")
    public String validate(@PathVariable("email") String email,
                           @PathVariable("code") String code) {
        return codeService.validate(email, code);
    }
}
